package master;

/**
 * @author chenyw
 * @date 2022/8/25 17:09
 *
 ( 只出现一次的数字2
 */
public class M136singleNumber {
    public int singleNumber(int[] nums) {
        int ans = 0;
        for (int i = 0; i < 32; i++) {
            int total = 0;
            for (int num : nums) {
                total += ((num >> i) & 1);
            }
            if (total % 3 != 0) {
                ans |= (1 << i);
            }
        }
        return ans;
    }
}
